package ltd.hyangyang.vegetable.controller;

import ltd.hyangyang.vegetable.entity.User;
import ltd.hyangyang.vegetable.entity.UserAnalysis;
import ltd.hyangyang.vegetable.service.UserService;
import ltd.hyangyang.vegetable.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/useInfo")
    public Result<List<UserAnalysis>> useInfo(){
        List<UserAnalysis> userAnalyses = userService.useInfo();

        return Result.success(userAnalyses);
    }

    //用户访问量
    @RequestMapping("/visits")
    public Result<Integer> userVisits(){
        Integer userVisits = userService.userVisits();
        return Result.success(userVisits);
    }

    //用户数
    @RequestMapping("/userNumber")
    public Result<Integer> userNumber(){
        List<User> users = userService.getBaseMapper().selectList(null);
        return Result.success(users.size());
    }
    //今日新增用户数
    @RequestMapping("/addUserNumber")
    public Result<Integer> addUserNumber(){
       Integer addUserNumber = userService.addUserNumber();
       return Result.success(addUserNumber);
    }

}
